package cn.kxx.config;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
        /**
         * 将字符串转换成Date类型
         * @param dateStr 日期字符类
         * @param pattern 转换的格式
         */
        public static Date strToDate(String dateStr, String pattern) throws ParseException {
            SimpleDateFormat sdf = new SimpleDateFormat(pattern);
            return sdf.parse(dateStr);
        }

    /**
     * 将日期类型转换成字符串
     * @param date
     * @param pattern
     */
    public static String dateToStr(Date date,String pattern){
        SimpleDateFormat sdf = new SimpleDateFormat(pattern);
        return sdf.format(date);
    }
    }